Deep Learning in image processing

Ivan Belyavtsev

17.11.2017

About me

Ivan Belyavtsev

post-graduate student

site: djbelyak.ru

About lectures

  1. Image processing
  2. Reinforcement learning
  3. Text processing

Lectures Approach

  • Practice
  • Understanding
  • A state of art

What do I expect from students

  • Understanding of neural networks
  • Basic of Python
  • Interest

What do you know about neuron networks?

Deep Learning in image processing

  1. Classification
  2. Denoising
  3. Upsampling
  4. Segmentation
  5. Object detection
  6. Style transfer

Data-driven approach

  1. Collect dataset (ex. pairs of images and label)
  2. Train a “black-box” on the dataset
  3. Evaluate the “black-box”

Well-known datasets: MNIST

Training set: 60000 examples. Test set: 10000 examples. Example: 28x28x1 image.

MNIST dataset

Well-known datasets: CIFAR-10

Training set: 50000 examples. Test set: 10000 examples. Example: 32x32x3 image in 10 classes.

CIFAR-10

Well-known datasets: ImageNet

Training set: 50000 examples. Test set: 15000 examples. Example: images in 1000 classes.

ImageNet

Stack of technology

  1. Python
  2. Numpy/Scipy
  3. TensorFlow
  4. Keras

Installing: Anaconda

  1. Download distributive from anaconda https://www.anaconda.com/download/
  2. Install it
  3. Create a conda enviroment
  4. Activate enviroment
> conda create -n tf python=3.5
> activate tf
(tf) >

Installing: SciPy stack

(tf) > pip install numpy scipy matplotlib ipython jupyter pandas sympy nose

Installing: TensorFlow

(tf) > pip install --ignore-installed --upgrade tensorflow

If you have an NVIDIA GPU use these instructions

Installing: Keras

(tf) > pip install keras

Multilayer perceptron example: data loading

(x_train, y_train), (x_test, y_test) = mnist.load_data()

Multilayer perceptron example: data preprocessing

x_train = x_train.reshape(60000, 784)
x_test = x_test.reshape(10000, 784)
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /= 255
x_test /= 255
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)

Multilayer perceptron example: define a model

model = Sequential()
model.add(Dense(512, activation='relu', input_shape=(784,)))
model.add(Dropout(0.2))
model.add(Dense(512, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(num_classes, activation='softmax'))

model.compile(loss='categorical_crossentropy',
              optimizer=RMSprop(),
              metrics=['accuracy'])

Multilayer perceptron example: fit and evaluete

history = model.fit(x_train, y_train,
                    batch_size=batch_size,
                    epochs=epochs,
                    verbose=1,
                    validation_data=(x_test, y_test))
score = model.evaluate(x_test, y_test, verbose=0)

What are the problems?

Convolutional NN

This image is CC BY-SA 4.0

Example: LeNet-5

Convolutional Layer

This image is CC BY-SA 3.0

Subsampling Layer

This image is CC BY-SA 4.0

CNN example: model

model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
                 activation='relu',
                 input_shape=input_shape))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))

model.compile(loss=keras.losses.categorical_crossentropy,
              optimizer=keras.optimizers.Adadelta(),
              metrics=['accuracy'])

CNN example: fit and evaluate

model.fit(x_train, y_train,
          batch_size=batch_size,
          epochs=epochs,
          verbose=1,
          validation_data=(x_test, y_test))
score = model.evaluate(x_test, y_test, verbose=0)

References

  1. MNIST dataset
  2. CIFAR-10
  3. ImageNet
  4. TensorFlow installation guide
  5. Scipy installation guide
  6. Keras MNIST example
  7. Notes for Stanford CS231n class
  8. LeNet-5